﻿@page "/initialization"
@inject IPoetryStorage _poetryStorage
@inject INavigationService _navigationService
@inject IFavoriteStorage _favoriteStorage

<div class="text-center">
    <div class="shim-2xl"></div>
    <h1>
        <Spinner></Spinner>
    </h1>
</div>

@code {

    protected override async Task OnAfterRenderAsync(bool firstRender) {
        if (!firstRender) {
            return;
        }

        if (!_poetryStorage.IsInitialized) {
            await _poetryStorage.InitializeAsync();
        }

        if (!_favoriteStorage.IsInitialized) {
            await _favoriteStorage.InitializeAsync();
        }

        await Task.Delay(1000);

        _navigationService.NavigateTo(NavigationServiceConstants.TodayPage);
    }

}